<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="lib/vue.global.js"></script>
</head>
<body>
  <div id="root">
    {{ count }} <button @click="add">add</button> {{ data.title }}
  </div>
</body>
<script type="module">
  const { createApp, reactive, ref, watchEffect, watch, onMounted } = window.Vue
  const app = createApp({
    setup(props) {
      const count = ref(100)

      const data = reactive({
        title: 'hello'
      })

      const add = () => {
        count.value += 10
      }
      onMounted(() => {
        data.title = 'world'
      })

      // watch(() => {
      //   return data.title
      // }, (newVal, oldVal) => {
      //   console.log(newVal, oldVal)
      // })

      // watch(() => {
      //   return count.value
      // }, (newVal, oldVal) => {
      //   console.log(newVal, oldVal)
      // })

      watch([
        () => {return count.value},
        () => {return data.title}
      ], ([newVal1, newVal2], [oldVal1, oldVal2]) => {
        console.log(newVal1, oldVal1)
        console.log(newVal2, oldVal2)
      })


      return {
        count,
        add,
        data
      }
    }
  })

  app.mount('#root')
</script>
</html>